/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OLA_SERVICE_H
#define OLA_SERVICE_H
#include "ola_sdk_api.h"
#include "ola_coap_net.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
 * 功能: 设备属性查询处理函数
 * 参数: ses，request所属会话
 *       pkt，收到的coap报文
 *       outData，回复的内容
 *       id，请求id，如果需要异步回复
 * 返回: OLA_OK，处理成功
 *       OLA_ERROR，处理失败
 */
int OlaQueryDeviceProperties(OlaCoapSession *ses, const OlaCoapPacket *pkt, OlaData *outData, OlaReqId reqId);

/*
 * 功能: 设备属性控制处理函数
 * 参数: ses，request所属会话
 *       pkt，收到的coap报文
 *       outData，回复的内容
 *       id，请求id，如果需要异步回复
 * 返回: OLA_OK，处理成功
 *       OLA_ERROR，处理失败
 *       OLA_ASYN，异步处理
 */
int OlaControlDeviceProperties(OlaCoapSession *ses, const OlaCoapPacket *pkt, OlaData *outData, OlaReqId reqId);

/*
 * 功能: 上报服务属性/事件
 * 参数: json，待上报的json数据
 *       id，异步控制时携带的标识符
 * 返回: OLA_OK，上报成功
 *       OLA_ERROR，上报失败
 */
int OlaReportDeviceProperties(const OlaData *json, OlaReqId id);

/*
 * 功能: 控制终端主动查询设备属性接口实现
 * 返回: OLA_OK，设备服务属性上报成功
 *       OLA_ERROR，设备服务属性上报失败
 */
int OlaGetServiceHandler(OlaCoapSession *session, const OlaCoapPacket *pkt, OlaData *outData, OlaReqId reqId);

#ifdef __cplusplus
}
#endif

#endif